<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = [3,4,1,2,5,6]
        let arrobj = [
            {
                age:3
            },
            {
                age:4
            },
            {
                age:1
            },
            {
                age:2
            },
            {
                age:5
            },
            {
                age:6
            }
        ]
        let maxTop = Math.max.apply(null,arr)
        let maxTopobj = Math.max.apply(null,arrobj)
        console.log(maxTop)
        console.log(maxTopobj)
        let maxTopEs6 = Math.max(...arr)
        console.log(maxTopEs6)
        let maxTopEstobj = Math.max(...arrobj)
        console.log(maxTopEstobj)

        //reduce写法
        let reduceTop = arr.reduce((currentValue,newvalue)=>{
           return  currentValue = currentValue >newvalue ? currentValue : newvalue
        })
        let reduceTopObj = arrobj.reduce((currentValue,newvalue)=>{
           return  currentValue = currentValue.age > newvalue.age ? currentValue : newvalue
        })
        console.log(reduceTop)
        console.log(reduceTopObj)
    </script>
</body>
</html>